// table项
let propList = [
  { prop: "ordersNo", label: "订单编号", width: 400 },
  { prop: "totalPrice", label: "订单总价" },
  { prop: "nickName", label: "商品购买人" },
  { prop: "createTime", label: "订单生成日期" },
  { prop: "address", label: "地址" },
  { label: "订单商品", slotName: "goodsInfo" },
  { label: "订单状态", slotName: "goodsStatus" },
  { label: "操作", slotName: "operation" },
];

// 表单配置
let formConfig = [
  {
    label: '订单编号',
    prop: 'ordersNo',
    type: 'input',
    width: '150px'
  },
  {
    label: '商品购买人',
    prop: 'userId',
    type: 'select',
    width: '150px',
    options: []
  },
  {
    label: '订单商品',
    prop: 'productId',
    type: 'select',
    width: '150px',
    options: []
  },
  {
    label: '订单生成日期',
    prop: 'orderCreateTime',
    type: 'daterange',
    width: '300px'
  }
]
// -----------------
let productListData = []
let userList = []
import AgriculturalSortManagement from '@/api/module/agricultural-sort-management'
import SystemUserManagement from '@/api/module/system-user-management'
function queryProductList () {
  let productList = []
  AgriculturalSortManagement.queryByCondition({}).then(res => {
    console.log(res.data)
    if (res.data && res.data.length > 0) {
      res.data.forEach(item => {
        productList.push({
          label: item.productName,
          value: item.productId
        })
      })
    }

    formConfig.forEach(item => {
      if (item.label == "订单商品") {
        item.options = productList
      }
    })
    productListData = productList
  })
}
function queryUserList () {
  let productList = []
  SystemUserManagement.queryByCondition({ userType: "custom_user" }).then(res => {
    if (res.data && res.data.length > 0) {
      res.data.forEach(item => {
        productList.push({
          label: item.nickName,
          value: item.userId
        })
      })
    }

    formConfig.forEach(item => {
      if (item.label == "商品购买人") {
        item.options = productList
      }
    })
    userList = productList
  })
}
queryProductList();
queryUserList();
export { propList, formConfig, productListData, userList }